Unit AFETrans;

								INTERFACE

Uses							
{$LOAD MacLoad.L}	MemTypes,QuickDraw,osIntf,toolIntf,packIntf,macPrint,script;

CONST
  {* translator routine commands *}
    trn_Init      = 0;	{ do any translator routine initialization }
    trn_Finis     = 1;	{ do any clean up and disposal }
    trn_Get       = 2;	{ Return current status }
	trn_Set		  = 3;	{ Set current status }
    trn_Active    = 4;	{ User has requested item be checked in menu }
    trn_Inactive  = 5;	{ User has requested item be unchecked in menu }
	trn_NewName	  = 6;	{ If recognized, return new name for selected file }
	trn_File	  = 7;	{ If recognized, convert the selected file }
	trn_Recognize = 8;	{ Return NoErr if selected file is recognized }
	trn_Appear	  = 9;	{ This routine is now listed in a menu }
	trn_Disappear = 10;	{ This routine is no longer listed in a menu }
	trn_Load	  = 11; { Pre-load any resources you might need }
	trn_About	  = 12; { Provide "About this translator" information }
	trn_GetSettings=13;	{ Get default information about the translator }
	trn_SetSettings=14; { Set default information about the translator }
	
  {* translator status bits *}
	trnActive	= $0001;	{ item is checked }
	trnGray		= $0002;	{ item is grayed-out }
	trnBold		= $0010;	{ item is bold }
	trnItalic	= $0020;	{ item is italicized }
	trnUnderline= $0040;	{ item is underlined }
	trnOutline	= $0080;	{ item is outlined }
	trnShadow	= $0100;	{ item is shadowed }
	trnAbout	= $0200;	{ About information is available for the item}
	trnUser1	= $1000;	{ user bit 1 }
	trnUser2	= $2000;	{ user bit 2 }
	trnUser3	= $4000;	{ user bit 3 }
	
  {* miscellaneous constants *}

	maxdestnames = 15;
	
	accept 		= noerr;
	unAccept	= 1;
	trnCancel	= 2;

  {* File system op codes *}
	FFGetVInfo		= 1;	FFSetVInfo		= 2;	FFFlushVol		= 5;
	FFOpen			= 9;	FFOpenRF		= 10;	FFLockRange		= 11;
	FFUnLockRange	= 12;	FFRead			= 13;	FFWrite			= 14;
	FFGetFPos		= 15;	FFSetFPos		= 16;	FFGetEOF		= 17;
	FFSetEOF		= 18;	FFAllocate		= 19;	FFAllocContig	= 20;
	FFFlushFile		= 21;	FFClose			= 22;	FFCreate		= 23;
	FFDirCreate		= 24;	FFDelete		= 25;	FFGetFInfo		= 26;
	FFSetFInfo		= 27;	FFSetFLock		= 28;	FFRstFLock		= 29;
	FFSetFVers		= 30;	FFRename		= 31;	FFGetCatInfo	= 32;
	FFSetCatInfo	= 33;	FFOpenWD		= 35;	FFCloseWD		= 36;
	FFGetWDInfo		= 37;	FFOKFName		= 41;	FFMakeFName		= 47;
	FFXGetCatInfo	= 50;	FFXSetCatInfo	= 51;
		
	foreignFS 		= '4NFS';

  {* Extended CatInfo constants *}
 
 	mdos		= 'mdos';
	pdos		= 'pdos';
	
	{ProDOS access bits}
	pdReadable	= $01;				{ File may be read }
	pdWritable	= $02;				{ File may be written to }
	pdChanged	= $20;				{ File has changed since last backup }
	pdRename	= $40;				{ File may be renamed }
	pdDestroy	= $80;				{ File may be destroyed }
	
	pdNormal	= $C3;				{ A normal ProDOS file }
	pdLocked	= $01;				{ A locked ProDOS file }
	
	{ProDOS storage types}
	pdSeedling	= $01;				{ File is a seedling, only one data block }
	pdSapling	= $02;				{ File is a sapling, 2 to 256 data blocks }
	pdTree		= $03;				{ File is a tree, 257 to 32768 data blocks }
	pdSubDir	= $0D;				{ File is a subdirectory }

	{ProDOS version numbers}
	ProDos1_0	= 0;				{ ProDOS 1.0 }
	
	{MSDOS Attribute bits}
	msReadOnly	= $01;				{ File is read-only }
	msHidden	= $02;				{ File is hidden }
	msSystem	= $04;				{ File is a system file }
	msVolume	= $08;				{ Directory is the root }
	msSubDir	= $10;				{ File is a subdirectory }
	msArchive	= $20;				{ File has been written to and closed }

	{****************************************************
	 *
	 * constants for tprocs
	 *
	 ***************************************************}
	
	tDstTooShort = -501;
	
	cfMacintosh	=	0;
	cfASCIi		=	1;
	cfIBMPC		=	2;
	
	transInit	=	0;
	transDone	=	1;
	translotohi	=	2;
	transhitolo	=	3;
	
	trMultiDestFont 	=	1;
	trMultiDestCountry	=	2;
	trNonOnetoOne		=	4;
	trOverStrike		=	8;

TYPE
    nameREC = RECORD
        namecnt : integer;
        names   : array[0..maxdestnames] of str255;
        end;
    nameptr = ^nameRec;
    namehdl = ^nameptr;

	translateRec = RECORD
		trnLogproc	:	procptr;	{ pointer to error log procedure }
		trnstatproc	:	procptr;	{ pointer to status procedure }
		trnfrID		:	integer;	{ resource ID of source FS }
		trntoID		:	integer;	{ resource ID of dest FS }
		trnfrData	:	ptr;		{ pointer to source FS global data }
		trntoData	:	ptr;		{ pointer to dest FS global data }
        trnResrv    : 	integer;	{ used by InterFile }
		trnfrVRef	:	integer;	{ volume ref of source }
		trntoVRef	:	integer;	{ volume ref of dest }
		trnfrPar	:	longint;	{ parent ID of source }
		trntoPar	:	longint;	{ parent ID of dest }
		trnnames	:	namehdl;	{ handle to names of source/dest files}
		trnTested	:	boolean;	{ TRUE if you've already looked at this
										file for recognition }
		trnAccepted	:	boolean;	{if TRNTESTED is true, this flag shows
										whether you recognized the file }
		trnCountry	:	integer;	{ country ID }
		END;
	trnPtr = ^translateRec;

  {* parameter blocks for extended CatInfo calls *}

	XFSType 	= (Mac,ProDOS,MSDOS);
	XCInfoPtr 	= ^XCInfoPBRec;
	XCInfoPBRec = RECORD
	{ In the memo this was descrived as a pointer not a record }
		CInfo: CInfoPBRec;
		CASE xfs : XFSType OF
			Mac : 
				(filler3	: longint);
			ProDOS :
				(auxtype	: integer; { ProDOS auxilary file type }
				access		: signedbyte;{ read,write perm etc. }
				storagetype	: signedbyte;{ seedling,sapling, etc }
				version		: signedbyte;{ version ProDOS used }
				minvers		: signedbyte);{ earliest ProDOS version useable }
			MSDOS :
				(attrib		: signedbyte; { read,write, hidden, etc }
				filler4		: signedbyte);
		END;
	
	pdosHndl	= ^pdosPtr;
	pdosPtr		= ^pdosRec;
	pdosRec		= RECORD
		auxtype		: integer;
		access		: signedbyte;
		storagetype	: signedbyte;
		version		: signedbyte;
		minvers		: signedbyte;
		END;
		
	
	mdosHndl	= ^mdosPtr;
	mdosPtr		= ^mdosRec;
	mdosRec		= RECORD
		attrib		: signedbyte;
		filler3		: signedbyte;
		END;

	TPRCEntry = RECORD
		tprcID 		: integer;
		curCharFam	: integer;
		altCountry	: integer;
		altCharFam	: integer;
		end;
		
	tprf = RECORD
		lastEntry	: integer;
		reserved	: array[1..31] of integer;
		tprocs		: array[1..1000] of TPRCEntry;
		end;
	tprfPtr = ^tprf;
	tprfHndl = ^tprfPtr;

	header = RECORD
		branch	: longint;
		sig		: resType;
		resnum	: integer;
		versnum	: integer;
		vers	: string[15];
		flags	: integer;
		loCntry	: integer;
		loCFam	: integer;
		hiCntry	: integer;
		hiCFam	: integer;
		hdrrsrv	: array[0..3] of longint;
		end;
	hdrPtr = ^header;
	hdrHndl = ^hdrPtr;

	TransText = RECORD
		trPtr	: Ptr;
		trLen	: Longint;
		trFont	: integer;
		end;
	
	TransPB = RECORD
		verb		: integer;
		featureflags: integer;
		result		: OSErr;
		newCntry	: integer;
		srcText		: TransText;
		dstText		: TransText;
		tpRsrv		: array[0..3] of longint;
		end;


function CallFS(msg : integer; fsdata : ptr; pb :ptr; 
				async : boolean; fsroutine : handle) : OSErr;
	INLINE $2057,$2050,$4E90;

procedure CallLog(str : str255; cr : boolean; Indent : boolean; Logproc : procptr);
	INLINE $205F, $1F5F, $0001, $4E90;

procedure CallErrLog(str : str255; cr : boolean; Indent : boolean; Logproc : procptr);
	INLINE $205F, $1F5F, $0001, $002F, $0080, $0001, $4E90;

function CallStat(statmsg : str255; statpct : integer; destfnum : integer;
				statproc : procptr) : boolean;
	INLINE $205F, $4E90;

function CallTProc(VAR params : TransPB; self : hdrHndl) : OSErr;
	INLINE $2057,$2050,$4E90;


								IMPLEMENTATION

end.